home *** CD-ROM | disk | FTP | other *** search
- package sun.font;
-
- import java.security.AccessController;
- import java.util.Locale;
- import sun.security.action.GetPropertyAction;
-
- public final class CompositeFont extends Font2D {
- private boolean[] deferredInitialisation;
- String[] componentFileNames;
- String[] componentNames;
- private PhysicalFont[] components;
- int numSlots;
- int numMetricsSlots;
- int[] exclusionRanges;
- int[] maxIndices;
- int numGlyphs = 0;
- int localeSlot = -1;
- boolean isStdComposite = true;
-
- public CompositeFont(String var1, String[] var2, String[] var3, int var4, int[] var5, int[] var6, boolean var7) {
- this.handle = new Font2DHandle(this);
- this.fullName = var1;
- this.componentFileNames = var2;
- this.componentNames = var3;
- if (var3 == null) {
- this.numSlots = this.componentFileNames.length;
- } else {
- this.numSlots = this.componentNames.length;
- }
-
- this.numMetricsSlots = var4;
- this.exclusionRanges = var5;
- this.maxIndices = var6;
- if (FontManager.eudcFont != null) {
- ++this.numSlots;
- if (this.componentNames != null) {
- this.componentNames = new String[this.numSlots];
- System.arraycopy(var3, 0, this.componentNames, 0, this.numSlots - 1);
- this.componentNames[this.numSlots - 1] = FontManager.eudcFont.getFontName((Locale)null);
- }
-
- if (this.componentFileNames != null) {
- this.componentFileNames = new String[this.numSlots];
- System.arraycopy(var2, 0, this.componentFileNames, 0, this.numSlots - 1);
- }
-
- this.components = new PhysicalFont[this.numSlots];
- this.components[this.numSlots - 1] = FontManager.eudcFont;
- this.deferredInitialisation = new boolean[this.numSlots];
- if (var7) {
- for(int var8 = 0; var8 < this.numSlots - 1; ++var8) {
- this.deferredInitialisation[var8] = true;
- }
- }
- } else {
- this.components = new PhysicalFont[this.numSlots];
- this.deferredInitialisation = new boolean[this.numSlots];
- if (var7) {
- for(int var10 = 0; var10 < this.numSlots; ++var10) {
- this.deferredInitialisation[var10] = true;
- }
- }
- }
-
- this.fontRank = 2;
- int var11 = this.fullName.indexOf(46);
- if (var11 > 0) {
- this.familyName = this.fullName.substring(0, var11);
- if (var11 + 1 < this.fullName.length()) {
- String var9 = this.fullName.substring(var11 + 1);
- if ("plain".equals(var9)) {
- this.style = 0;
- } else if ("bold".equals(var9)) {
- this.style = 1;
- } else if ("italic".equals(var9)) {
- this.style = 2;
- } else if ("bolditalic".equals(var9)) {
- this.style = 3;
- }
- }
- } else {
- this.familyName = this.fullName;
- }
-
- }
-
- CompositeFont(PhysicalFont var1, CompositeFont var2) {
- this.isStdComposite = false;
- this.handle = new Font2DHandle(this);
- this.fullName = var1.fullName;
- this.familyName = var1.familyName;
- this.style = var1.style;
- this.numMetricsSlots = 1;
- this.numSlots = var2.numSlots + 1;
- synchronized(FontManager.class) {
- this.components = new PhysicalFont[this.numSlots];
- this.components[0] = var1;
- System.arraycopy(var2.components, 0, this.components, 1, var2.numSlots);
- if (var2.componentNames != null) {
- this.componentNames = new String[this.numSlots];
- this.componentNames[0] = var1.fullName;
- System.arraycopy(var2.componentNames, 0, this.componentNames, 1, var2.numSlots);
- }
-
- if (var2.componentFileNames != null) {
- this.componentFileNames = new String[this.numSlots];
- this.componentFileNames[0] = null;
- System.arraycopy(var2.componentFileNames, 0, this.componentFileNames, 1, var2.numSlots);
- }
-
- this.deferredInitialisation = new boolean[this.numSlots];
- this.deferredInitialisation[0] = false;
- System.arraycopy(var2.deferredInitialisation, 0, this.deferredInitialisation, 1, var2.numSlots);
- }
- }
-
- private void doDeferredInitialisation(int var1) {
- if (this.deferredInitialisation[var1]) {
- synchronized(FontManager.class) {
- if (this.componentNames == null) {
- this.componentNames = new String[this.numSlots];
- }
-
- if (this.components[var1] == null) {
- if (this.componentFileNames != null && this.componentFileNames[var1] != null) {
- this.components[var1] = FontManager.initialiseDeferredFont(this.componentFileNames[var1]);
- }
-
- if (this.components[var1] == null) {
- this.components[var1] = FontManager.getDefaultPhysicalFont();
- }
-
- String var3 = this.components[var1].getFontName((Locale)null);
- if (this.componentNames[var1] == null) {
- this.componentNames[var1] = var3;
- } else if (!this.componentNames[var1].equalsIgnoreCase(var3)) {
- this.components[var1] = (PhysicalFont)FontManager.findFont2D(this.componentNames[var1], this.style, 1);
- }
- }
-
- this.deferredInitialisation[var1] = false;
- }
- }
- }
-
- void replaceComponentFont(PhysicalFont var1, PhysicalFont var2) {
- if (this.components != null) {
- for(int var3 = 0; var3 < this.numSlots; ++var3) {
- if (this.components[var3] == var1) {
- this.components[var3] = var2;
- if (this.componentNames != null) {
- this.componentNames[var3] = var2.getFontName((Locale)null);
- }
- }
- }
-
- }
- }
-
- public boolean isExcludedChar(int var1, int var2) {
- if (this.exclusionRanges != null && this.maxIndices != null && var1 < this.numMetricsSlots) {
- int var3 = 0;
- int var4 = this.maxIndices[var1];
- if (var1 > 0) {
- var3 = this.maxIndices[var1 - 1];
- }
-
- for(int var5 = var3; var4 > var5; var5 += 2) {
- if (var2 >= this.exclusionRanges[var5] && var2 <= this.exclusionRanges[var5 + 1]) {
- return true;
- }
- }
-
- return false;
- } else {
- return false;
- }
- }
-
- public void getStyleMetrics(float var1, float[] var2, int var3) {
- PhysicalFont var4 = this.getSlotFont(0);
- if (var4 == null) {
- super.getStyleMetrics(var1, var2, var3);
- } else {
- var4.getStyleMetrics(var1, var2, var3);
- }
-
- }
-
- public int getNumSlots() {
- return this.numSlots;
- }
-
- public PhysicalFont getSlotFont(int var1) {
- if (this.deferredInitialisation[var1]) {
- this.doDeferredInitialisation(var1);
- }
-
- try {
- PhysicalFont var2 = this.components[var1];
- if (var2 == null) {
- try {
- var2 = (PhysicalFont)FontManager.findFont2D(this.componentNames[var1], this.style, 1);
- this.components[var1] = var2;
- } catch (ClassCastException var4) {
- var2 = FontManager.getDefaultPhysicalFont();
- }
- }
-
- return var2;
- } catch (Exception var5) {
- return FontManager.getDefaultPhysicalFont();
- }
- }
-
- FontStrike createStrike(FontStrikeDesc var1) {
- return new CompositeStrike(this, var1);
- }
-
- public boolean isStdComposite() {
- return this.isStdComposite;
- }
-
- protected int getValidatedGlyphCode(int var1) {
- int var2 = var1 >>> 24;
- if (var2 >= this.numSlots) {
- return this.getMapper().getMissingGlyphCode();
- } else {
- int var3 = var1 & 16777215;
- PhysicalFont var4 = this.getSlotFont(var2);
- return var4.getValidatedGlyphCode(var3) == var4.getMissingGlyphCode() ? this.getMapper().getMissingGlyphCode() : var1;
- }
- }
-
- public CharToGlyphMapper getMapper() {
- if (this.mapper == null) {
- this.mapper = new CompositeGlyphMapper(this);
- }
-
- return this.mapper;
- }
-
- public boolean hasSupplementaryChars() {
- for(int var1 = 0; var1 < this.numSlots; ++var1) {
- if (this.getSlotFont(var1).hasSupplementaryChars()) {
- return true;
- }
- }
-
- return false;
- }
-
- public int getNumGlyphs() {
- if (this.numGlyphs == 0) {
- this.numGlyphs = this.getMapper().getNumGlyphs();
- }
-
- return this.numGlyphs;
- }
-
- public int getMissingGlyphCode() {
- return this.getMapper().getMissingGlyphCode();
- }
-
- public boolean canDisplay(char var1) {
- return this.getMapper().canDisplay(var1);
- }
-
- public boolean useAAForPtSize(int var1) {
- if (this.localeSlot == -1) {
- int var2 = this.numMetricsSlots;
- if (var2 == 1 && !this.isStdComposite()) {
- var2 = this.numSlots;
- }
-
- for(int var3 = 0; var3 < var2; ++var3) {
- if (this.getSlotFont(var3).supportsEncoding((String)null)) {
- this.localeSlot = var3;
- break;
- }
- }
-
- if (this.localeSlot == -1) {
- this.localeSlot = 0;
- }
- }
-
- return this.getSlotFont(this.localeSlot).useAAForPtSize(var1);
- }
-
- public String toString() {
- String var1 = (String)AccessController.doPrivileged(new GetPropertyAction("line.separator"));
- String var2 = "";
-
- for(int var3 = 0; var3 < this.numSlots; ++var3) {
- var2 = var2 + " Slot[" + var3 + "]=" + this.getSlotFont(var3) + var1;
- }
-
- return "** Composite Font: Family=" + this.familyName + " Name=" + this.fullName + " style=" + this.style + var1 + var2;
- }
- }
-